package com.lamatek.tags.google;

import java.io.Serializable;

import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapIconTag
 * 
 * This class represents a &lt;googlemaps:icon> tag. Developers should not override this class.
 * 
 * @author Tom Cole
 * @version 0.40
 */
public class GoogleMapIconTag extends TagSupport implements Serializable {

    String icon = null;
    String shadow = null;
    int iconWidth = 0;
    int iconHeight = 0;
    int shadowWidth = 0;
    int shadowHeight = 0;
    int anchorX = 0;
    int anchorY = 0;
    int infoWindowAnchorX = 0;
    int infoWindowAnchorY = 0;
    /**
     * Overrides doStartTag() from TagSupport. Developers should not override this method.
     */
    public int doStartTag() {
        Tag tag = this;
        while (tag.getParent() != null) {
            if (tag.getParent() instanceof GoogleMapMarkerTag) {
                ((GoogleMapMarkerTag) tag.getParent()).setIcon(this);
                return SKIP_BODY;
            }
            else if (tag.getParent() instanceof GoogleMapTrafficTag) {
                ((GoogleMapTrafficTag) tag.getParent()).setIcon(this);
                return SKIP_BODY;
            }
            else if (tag.getParent() instanceof GoogleMapClusterTag) {
                ((GoogleMapClusterTag) tag.getParent()).setIcon(this);
                return SKIP_BODY;
            }
            tag = tag.getParent();
        }
        return SKIP_BODY;
    }
    /**
     * Returns the anchor point for the icon's x axis. 
     * 
     * @return The anochor point x axis.
     */
    public int getAnchorX() {
        return anchorX;
    }
    /**
     * Sets the x axis value for the icon's anchor point. This is the point of the icon
     * that is placed at the specified longitude/latitude of the parent marker's point.
     * 
     * @param anchorX The x axis value for the anchor point.
     */
    public void setAnchorX(int anchorX) {
        this.anchorX = anchorX;
    }
    /**
     * Returns the anchor point for the icon's y axis. 
     * 
     * @return The anochor point y axis.
     */
    public int getAnchorY() {
        return anchorY;
    }
    /**
     * Sets the y axis value for the icon's anchor point. This is the point of the icon
     * that is placed at the specified longitude/latitude of the parent marker's point.
     * 
     * @param anchorY The y axis value for the anchor point.
     */
    public void setAnchorY(int anchorY) {
        this.anchorY = anchorY;
    }
    /**
     * Returns the url of the resource used as the image for this icon. This image
     * should be 24-bit PNG with transparency for maximum effect.
     * 
     * @return A url that points to an image. 
     */
    public String getIcon() {
        return icon;
    }
    /**
     * Sets the url of the resource to be used as the image for this icon. This resouce
     * should be 24-bit PNG with transparency for maximum effect.
     * 
     * @param icon A url that points to an image. 
     */
    public void setIcon(String icon) {
        this.icon = icon;
    }
    /**
     * Returns the height (in pixels) that this icon image should be rendered.
     * 
     * @return An int specifying icon height.
     */
    public int getIconHeight() {
        return iconHeight;
    }
    /**
     * Sets the height (in pixels) that this icon image should be rendered.
     * 
     * @param iconHeight An int specifying icon height.
     */
    public void setIconHeight(int iconHeight) {
        this.iconHeight = iconHeight;
    }
    /**
     * Returns the width (in pixels) that this icon image should be rendered.
     * 
     * @return An int specifying icon width.
     */
    public int getIconWidth() {
        return iconWidth;
    }
    /**
     * Sets the width (in pixels) that this icon image should be rendered.
     * 
     * @param iconWidth An int specifying icon width.
     */
    public void setIconWidth(int iconWidth) {
        this.iconWidth = iconWidth;
    }
    /**
     * Returns the x axis of where an info window will anchor itself to the icon.
     * 
     * @return An int specifying x axis of info window anchor point.
     */
    public int getInfoWindowAnchorX() {
        return infoWindowAnchorX;
    }
    /**
     * Sets the x axis of where an info window will anchor itself to the icon.
     * 
     * @param infoWindowAnchorX An int specifying x axis of info window anchor point.
     */
    public void setInfoWindowAnchorX(int infoWindowAnchorX) {
        this.infoWindowAnchorX = infoWindowAnchorX;
    }
    /**
     * Returns the y axis of where an info window will anchor itself to the icon.
     * 
     * @return An int specifying y axis of info window anchor point.
     */
    public int getInfoWindowAnchorY() {
        return infoWindowAnchorY;
    }
    /**
     * Sets the y axis of where an info window will anchor itself to the icon.
     * 
     * @param infoWindowAnchorY An int specifying y axis of info window anchor point.
     */
    public void setInfoWindowAnchorY(int infoWindowAnchorY) {
        this.infoWindowAnchorY = infoWindowAnchorY;
    }
    /**
     * Returns the url of the resource used as the image for this icon's shadow. This image
     * should be 24-bit PNG with transparency for maximum effect.
     * 
     * @return A url that points to an image. 
     */
    public String getShadow() {
        return shadow;
    }
    /**
     * Sets the url of the resource to be used as the image for this icon's shadow. This resouce
     * should be 24-bit PNG with transparency for maximum effect.
     * 
     * @param icon A url that points to an image. 
     */
    public void setShadow(String shadow) {
        this.shadow = shadow;
    }
    /**
     * Returns the height (in pixels) that this icon's shadow image should be rendered.
     * 
     * @return An int specifying icon height.
     */
    public int getShadowHeight() {
        return shadowHeight;
    }
    /**
     * Sets the height (in pixels) that this icon's shadow image should be rendered.
     * 
     * @param shadowHeight An int specifying icon height.
     */
    public void setShadowHeight(int shadowHeight) {
        this.shadowHeight = shadowHeight;
    }
    /**
     * Returns the width (in pixels) that this icon's shadow image should be rendered.
     * 
     * @return An int specifying icon width.
     */
    public int getShadowWidth() {
        return shadowWidth;
    }
    /**
     * Sets the width (in pixels) that this icon's shadow image should be rendered.
     * 
     * @param shadowWidth An int specifying icon width.
     */
    public void setShadowWidth(int shadowWidth) {
        this.shadowWidth = shadowWidth;
    }
}
